@echo off
echo ================================
echo 启动 SimpleTongHuaShun 程序
echo ================================
echo Step 1: 检查现有实例...
tasklist /FI "IMAGENAME eq SimpleTongHuaShun.exe" 2>NUL | find /I /N "SimpleTongHuaShun.exe">NUL
if "%ERRORLEVEL%"=="0" (
    echo 发现现有 SimpleTongHuaShun.exe 实例，正在终止...
    taskkill /F /IM SimpleTongHuaShun.exe >NUL 2>&1
    echo 已终止现有实例
    timeout /t 2 /nobreak >NUL
) else (
    echo 未发现现有实例
)
echo -------------------------------
echo Step 2: 更新代码到最新版本...
git pull origin master
if errorlevel 1 (
    echo Git pull 失败，但继续执行...
)
echo -------------------------------
echo Step 3: 编译项目...
dotnet build SimpleTongHuaShun.csproj -c Release -f net48
if errorlevel 1 (
    echo 编译失败！
    pause
    exit /b 1
)
echo -------------------------------
echo Step 4: 启动程序...
echo 正在启动 SimpleTongHuaShun.exe...
cd bin\Release\net48
SimpleTongHuaShun.exe
echo 程序已退出
pause
